package com.c2.service.impl;
import com.c2.entity.EbNews;
import com.c2.mapper.NewsMapper;
import com.c2.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewsServiceImpl implements NewsService {
    @Autowired
    private NewsMapper newsMapper;
    @Override
    public List<EbNews> listByPage(int page, int pageSize) {
        int from = (page-1)*pageSize;
        return newsMapper.findByPage(from,pageSize);
    }

    @Override
    public Integer getMaxPage(Integer pageSize) {
        return newsMapper.getMaxPage(pageSize);
    }

    @Override
    public Integer save(EbNews ebNews){
        return newsMapper.save(ebNews);
    }

    @Override
    public  Integer deleteById(Integer id){
        return newsMapper.remove(id);
    }

    @Override
    public EbNews selectById(Integer enId) {
        return newsMapper.selectById(enId);
    }

    @Override
    public Integer updateById(EbNews ebNews) { return newsMapper.updateByPrimaryKey(ebNews); }
}
